package org.meerkat.forum.client.threadslist;

import com.extjs.gxt.ui.client.event.IconButtonEvent;
import com.extjs.gxt.ui.client.event.SelectionListener;
import com.extjs.gxt.ui.client.widget.ContentPanel;
import com.extjs.gxt.ui.client.widget.Info;
import com.extjs.gxt.ui.client.widget.button.Button;
import com.extjs.gxt.ui.client.widget.button.ToolButton;

public class ThreadsListView extends ContentPanel {
	private final ThreadsList owner;

	private class CloseClickHandler extends SelectionListener<IconButtonEvent> {
		@Override
		public void componentSelected(IconButtonEvent ce) {
			removeFromParent();
		}
	}

	private class MinimizeClickHandler extends SelectionListener<IconButtonEvent> {
		@Override
		public void componentSelected(IconButtonEvent ce) {
			Info.display("Click", "Minimize");
		}
	}

	public ThreadsListView(ThreadsList owner) {
		this.owner = owner;
		setHeading(owner.getModel().getTitle());
		setHeaderVisible(true);
		head.addTool(new ToolButton("x-tool-minimize", new MinimizeClickHandler()));
		head.addTool(new ToolButton("x-tool-close", new CloseClickHandler()));
		add(new Button("Open new thread"));
	}

	/**
	 * @return the owner
	 */
	public ThreadsList getOwner() {
		return owner;
	}
}
